<!DOCTYPE html>


<html lang="en">


<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    git操作存储原理 |  一曲秋殇
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="/images/myfavicon.ico" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

</head>

</html>

<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-git/git操作存储原理"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  git操作存储原理
</h1>
 

    </header>
     
    <div class="article-meta">
      <a href="/git/git%E6%93%8D%E4%BD%9C%E5%AD%98%E5%82%A8%E5%8E%9F%E7%90%86/" class="article-date">
  <time datetime="2021-12-13T09:45:19.278Z" itemprop="datePublished">2021-12-13</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/git/">git</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">921</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">3 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><blockquote>
<p>本文涉及到的原图地址：<a target="_blank" rel="noopener" href="https://www.processon.com/view/link/604ccb1bf346fb78ada97e4c">原图地址</a></p>
</blockquote>
<h4 id="1-创建空项目并初始化git仓库"><a href="#1-创建空项目并初始化git仓库" class="headerlink" title="1. 创建空项目并初始化git仓库"></a>1. 创建空项目并初始化git仓库</h4><p>执行命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mkdir project</span><br><span class="line"><span class="built_in">cd</span> project</span><br><span class="line">git init</span><br></pre></td></tr></table></figure>
<p>执行完上面的命令后会在project目录中会生成一个.git的文件夹，执行<code>tree -a .git</code>后输出文件结构如下：</p>
<blockquote>
<p>如果是在windows中使用git base客户端进行操作找不到tree命令可先安装tree命令。先下载tree命令zip包<a target="_blank" rel="noopener" href="https://master.dl.sourceforge.net/project/gnuwin32/tree/1.5.2/tree-1.5.2-bin.zip?viasf=1">下载地址</a>，解压后将包中的那个可以执行文件放到git base安装目录的usr/bin文件夹中</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">.git</span><br><span class="line">|   `-- HEAD</span><br><span class="line">|   `-- config</span><br><span class="line">|   `-- description</span><br><span class="line">|   `-- hooks</span><br><span class="line">|   |-- applypatch-msg.sample</span><br><span class="line">|   |-- commit-msg.sample</span><br><span class="line">|   |-- post-update.sample</span><br><span class="line">|   |-- pre-applypatch.sample</span><br><span class="line">|   |-- pre-commit.sample</span><br><span class="line">|   |-- pre-push.sample</span><br><span class="line">|   |-- pre-rebase.sample</span><br><span class="line">|   |-- prepare-commit-msg.sample</span><br><span class="line">|   `-- update.sample</span><br><span class="line">|-- info</span><br><span class="line">|   `-- exclude</span><br><span class="line">|-- objects</span><br><span class="line">|   |-- info</span><br><span class="line">|   `-- pack</span><br><span class="line">`-- refs</span><br><span class="line">    |-- heads</span><br><span class="line">    `-- tags</span><br></pre></td></tr></table></figure>
<h4 id="2-往项目中添加a-txt和b-txt两个文件"><a href="#2-往项目中添加a-txt和b-txt两个文件" class="headerlink" title="2. 往项目中添加a.txt和b.txt两个文件"></a>2. 往项目中添加a.txt和b.txt两个文件</h4><p>执行命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> <span class="string">&#x27;111&#x27;</span> &gt; a.txt</span><br><span class="line"><span class="built_in">echo</span> <span class="string">&#x27;222&#x27;</span> &gt; b.txt </span><br></pre></td></tr></table></figure>
<p>此时.git文件夹中的内容依旧没有任何变化</p>
<h4 id="3-执行add操作"><a href="#3-执行add操作" class="headerlink" title="3. 执行add操作"></a>3. 执行add操作</h4><p>执行以下命令将a.txt和b.txt添加到暂存区：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git add ./*</span><br></pre></td></tr></table></figure>
<p>执行完add命令后会发现在objects目录中多出来了两个文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">|-- objects</span><br><span class="line">|   |-- 58</span><br><span class="line">|   |   `-- c9bdf9d017fcd178dc8c073cbfcbb7ff240d6c</span><br><span class="line">|   |-- c2</span><br><span class="line">|   |   `-- 00906efd24ec5e783bee7f23b5d7c941b0c12c</span><br></pre></td></tr></table></figure>
<p>直接输出这两个文件是乱码的，需要通过通过<code>git cat-file -p</code>命令进行查看内容，通过<code>git cat-file -t</code>能查看文件类型</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">$ git cat-file -p 58c9</span><br><span class="line">111</span><br><span class="line"></span><br><span class="line">$ git cat-file -p c200</span><br><span class="line">222</span><br><span class="line"></span><br><span class="line">$ git cat-file -t 58c9</span><br><span class="line">blob</span><br><span class="line"></span><br><span class="line">$ git cat-file -t c200</span><br><span class="line">blob</span><br></pre></td></tr></table></figure>
<p>此时工作区的文件会添加到暂存区，版本区没有变化<br><img src="http://img.luobiao.vip/img/20210313112505.jpg"></p>
<h4 id="4-执行commit操作"><a href="#4-执行commit操作" class="headerlink" title="4. 执行commit操作"></a>4. 执行commit操作</h4><p>执行以下命令将a.txt和b.txt添加到版本区：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git commit -m  <span class="string">&#x27;first commit&#x27;</span></span><br></pre></td></tr></table></figure>
<p>此时objects中又多出了两个文件，而且refs/heads文件夹中多了个master的文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">|-- objects</span><br><span class="line">|   |-- 4c</span><br><span class="line">|   |   `-- aaa1a9ae0b274fba9e3675f9ef071616e5b209 <span class="comment">##新增文件</span></span><br><span class="line">|   |-- 58</span><br><span class="line">|   |   `-- c9bdf9d017fcd178dc8c073cbfcbb7ff240d6c</span><br><span class="line">|   |-- 6d</span><br><span class="line">|   |   `-- 773cef4de0033d8a698805d74445ff5483645e <span class="comment">##新增文件</span></span><br><span class="line">|   |-- c2</span><br><span class="line">|   |   `-- 00906efd24ec5e783bee7f23b5d7c941b0c12c</span><br><span class="line">|   |-- info</span><br><span class="line">|   `-- pack</span><br><span class="line">`-- refs</span><br><span class="line">    |-- heads</span><br><span class="line">    |   `-- master  <span class="comment">##新增文件</span></span><br><span class="line">    `-- tags</span><br></pre></td></tr></table></figure>
<p>查看新增文件的内容和类型</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">$ git cat-file -p 4caa</span><br><span class="line">100644 blob 58c9bdf9d017fcd178dc8c073cbfcbb7ff240d6c    a.txt</span><br><span class="line">100644 blob c200906efd24ec5e783bee7f23b5d7c941b0c12c    b.txt</span><br><span class="line"></span><br><span class="line">$ git cat-file -p 6d77</span><br><span class="line">tree 4caaa1a9ae0b274fba9e3675f9ef071616e5b209</span><br><span class="line">author jackluo &lt;luobiao320@163.com&gt; 1615602585 +0800</span><br><span class="line">committer jackluo &lt;luobiao320@163.com&gt; 1615602585 +0800</span><br><span class="line">first commit</span><br><span class="line"></span><br><span class="line">$ git cat-file -t 4caa</span><br><span class="line">tree</span><br><span class="line"></span><br><span class="line">$ git cat-file -t 6d77</span><br><span class="line">commit</span><br><span class="line"></span><br><span class="line">$ cat .git/refs/heads/master</span><br><span class="line">6d773cef4de0033d8a698805d74445ff5483645e</span><br></pre></td></tr></table></figure>
<p>可以发现master文件中保存了commit文件hash，而commit文件中保存了tree文件hash值，tree文件中保存了commit时当前项目结构的hash快照<br>此时暂存区被清空，版本区中新增了版本信息<br><img src="http://img.luobiao.vip/img/20210313113040.jpg"></p>
<h4 id="5-修改a-txt并add"><a href="#5-修改a-txt并add" class="headerlink" title="5. 修改a.txt并add"></a>5. 修改a.txt并add</h4><p>执行如下命令</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> <span class="string">&#x27;1111&#x27;</span> &gt; a.txt</span><br><span class="line">git add ./a.txt </span><br></pre></td></tr></table></figure>
<p>执行add后objects文件夹中会多出一个文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">|-- objects</span><br><span class="line">|   |-- 4c</span><br><span class="line">|   |   `-- aaa1a9ae0b274fba9e3675f9ef071616e5b209</span><br><span class="line">|   |-- 58</span><br><span class="line">|   |   `-- c9bdf9d017fcd178dc8c073cbfcbb7ff240d6c</span><br><span class="line">|   |-- 5f</span><br><span class="line">|   |   `-- 2f16bfff90e6620509c0cf442e7a3586dad8fb <span class="comment">##新增文件</span></span><br><span class="line">|   |-- 6d</span><br><span class="line">|   |   `-- 773cef4de0033d8a698805d74445ff5483645e</span><br><span class="line">|   |-- c2</span><br><span class="line">|   |   `-- 00906efd24ec5e783bee7f23b5d7c941b0c12c</span><br></pre></td></tr></table></figure>
<p>查看新增文件的内容和类型</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ git cat-file -p 5f2f</span><br><span class="line">1111</span><br><span class="line"></span><br><span class="line">$ git cat-file -t 5f2f</span><br><span class="line">blob</span><br></pre></td></tr></table></figure>
<p>从输出结果可以看出在修改文件的时候是将修改后的文件全量添加到了暂存区，而不是增量的方式<br>通过此操作后工作区和暂存区都发生了变化<br><img src="http://img.luobiao.vip/img/20210313182916.jpg"></p>
<h4 id="6-提交a-txt的修改"><a href="#6-提交a-txt的修改" class="headerlink" title="6. 提交a.txt的修改"></a>6. 提交a.txt的修改</h4><p>执行如下命令</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git commit -m <span class="string">&#x27;second commit&#x27;</span></span><br></pre></td></tr></table></figure>
<p>执行commit后objects中新增了两个文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">|-- objects</span><br><span class="line">|   |-- 4c</span><br><span class="line">|   |   `-- aaa1a9ae0b274fba9e3675f9ef071616e5b209</span><br><span class="line">|   |-- 58</span><br><span class="line">|   |   `-- c9bdf9d017fcd178dc8c073cbfcbb7ff240d6c</span><br><span class="line">|   |-- 5f</span><br><span class="line">|   |   `-- 2f16bfff90e6620509c0cf442e7a3586dad8fb</span><br><span class="line">|   |-- 6d</span><br><span class="line">|   |   `-- 773cef4de0033d8a698805d74445ff5483645e</span><br><span class="line">|   |-- c2</span><br><span class="line">|   |   `-- 00906efd24ec5e783bee7f23b5d7c941b0c12c</span><br><span class="line">|   |-- e0</span><br><span class="line">|   |   |-- 0074cbe38ed0891957d3e4741b672c4897f6a1 <span class="comment">##新增文件</span></span><br><span class="line">|   |   `-- c96077b83d4ed7ebdbdfbb910c1febe58c6076 <span class="comment">##新增文件</span></span><br></pre></td></tr></table></figure>
<p>查看新增文件的内容</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">$ git cat-file -p e000</span><br><span class="line">tree e0c96077b83d4ed7ebdbdfbb910c1febe58c6076</span><br><span class="line">parent 6d773cef4de0033d8a698805d74445ff5483645e</span><br><span class="line">author jackluo &lt;luobiao320@163.com&gt; 1615631455 +0800</span><br><span class="line">committer jackluo &lt;luobiao320@163.com&gt; 1615631455 +0800</span><br><span class="line">second commit</span><br><span class="line"></span><br><span class="line">$ git cat-file -p e0c9</span><br><span class="line">100644 blob 5f2f16bfff90e6620509c0cf442e7a3586dad8fb    a.txt</span><br><span class="line">100644 blob c200906efd24ec5e783bee7f23b5d7c941b0c12c    b.txt</span><br></pre></td></tr></table></figure>
<p>此处的输出结果commit中多出了个parent，parent的值指向上一次commit的hash值6d77，而且此次提交中虽然没有涉及b.txt文件，但tree中依旧保存了b.txt文件的hash值，所以说每次commit时会保存整个项目结构的hash快照，而不是变更的那些文件的hash<br>执行此操作后缓冲区被清空，版本区发生变化<br><img src="http://img.luobiao.vip/img/20210313192309.jpg"></p>
<link rel="stylesheet" href="/css/spoiler.css" type="text/css"><script src="/js/spoiler.js" type="text/javascript" async></script> 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://luobiao320.gitee.io/git/git%E6%93%8D%E4%BD%9C%E5%AD%98%E5%82%A8%E5%8E%9F%E7%90%86/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/git/" rel="tag">git</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%8E%9F%E7%90%86/" rel="tag">原理</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86/" rel="tag">版本管理</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/git/git%E5%88%86%E6%94%AF%E6%93%8D%E4%BD%9C%E5%9B%BE%E8%A7%A3%E8%AF%B4%E6%98%8E/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            git分支操作图解说明
          
        </div>
      </a>
    
    
      <a href="/spring/security/springsecurity%E6%8E%88%E6%9D%83/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">springsecurity授权</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "kHx6wceVXdEyiCrLm0sLAwoF-gzGzoHsz",
    app_key: "ArEdGk6wzHOhrXLiwmClhDNH",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2020-2021
        <i class="ri-heart-fill heart_icon"></i> luobiao
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      
        <li>
          <a href="http://beian.miit.gov.cn/" target="_black" rel="nofollow">赣ICP备2020014719号-1</a>
        </li>
        
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="http://img.luobiao.vip/53119d0bda706bbe350333137a67ea3e_1.jpg" alt="一曲秋殇"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/dubbo">dubbo</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/spring">spring</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/mysql">mysql</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->


<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->

<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


    
  </div>
</body>

</html>